package com.czk.springdatar2dbc.controller;

import com.czk.springdatar2dbc.entity.TAuthor;
import com.czk.springdatar2dbc.repository.TAuthorRepository;
import jakarta.annotation.Resource;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;

import java.time.Duration;

/**
 * @Author: chenzhangkun
 * @CreateTime: 2025-05-27
 * @Description:
 * @Version: 1.0
 */
@RestController
public class TAuthorController {
    @Resource
    private TAuthorRepository authorRepository;

    @GetMapping(value = "getAll",produces = MediaType.TEXT_EVENT_STREAM_VALUE)
    public Flux<TAuthor> getAll() {
        return authorRepository.findAll().delayElements(Duration.ofSeconds(5L));
    }

}
